﻿using PureMVC.Interfaces;
using PureMVC.Patterns.Mediator;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// 中介者
/// </summary>
public class MyMediator : Mediator
{

    public new const string NAME = "MyMediator";
    private Text text;
    public MyMediator(GameObject root) : base(NAME)
    {
       Button button= root.transform.Find("Button").GetComponent<Button>();
        text= root.transform.Find("Text").GetComponent<Text>();
        button.onClick.AddListener(() => { SendNotification("Cmd_Add"); });
    }
    /// <summary>
    /// 注册事件
    /// </summary>
    /// <returns></returns>
    public override string[] ListNotificationInterests()
    {
        return new string[]{
            "Add",""
        };
    }
    /// <summary>
    /// 事件回调的方法
    /// </summary>
    /// <param name="notification"></param>
    public override void HandleNotification(INotification notification)
    {
        switch (notification.Name)
        {
            case "Add":

                text.text = (notification.Body as MyData).time;
                break;
            default:
                break;
        }
    }
}
